<template>
  <div class="app-container">
    <div class="head-container">
      <el-input v-model="params.tableName" clearable placeholder="请输入表名" style="width:150px;" class="filter-item"/>
      <el-input v-model="params.tableComment" clearable placeholder="请输入表描述" style="width:150px;" class="filter-item"/>
      <el-button type="success" size="mini" icon="el-icon-plus">建表</el-button>
      <el-button type="primary" size="mini" icon="el-icon-search" @click="handleQuery">搜索</el-button>
      <el-button type="button" size="mini" icon="el-icon-refresh">重置</el-button>
    </div>
    <el-table v-loading="loading" :data="data" :height="tableHeight" size="mini" fit border>
      <el-table-column type="index" width="40" align="center"/>
      <el-table-column prop="tableName" label="表名" header-align="center" width="150px" show-overflow-tooltip/>
      <el-table-column prop="tableComment" label="表描述" header-align="center" width="150px" show-overflow-tooltip/>
      <el-table-column prop="crt_time" label="创建时间" width="180px" align="center">
        <template slot-scope="scope">
          {{parseTime(scope.row.crtTime)}}
        </template>
      </el-table-column>
      <el-table-column prop="operate" label="操作" width="250px" align="center">
        <template slot-scope="scope">
          <el-button slot="reference"  type="text" size="mini" @click="handleUpdate(scope.row)">构建</el-button>
          <el-button slot="reference" type="text" size="mini" @click="handleView()">代码预览</el-button>
          <el-button slot="reference"  type="text" size="mini" @click="handleDelete(scope.row)">删除表</el-button>
          <el-button slot="reference" type="text" size="mini" >生成代码</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!--分页组件-->
    <el-pagination :total="total" style="margin-top: 8px;" layout="total, prev, pager, next, sizes" :page-size="20"
      @size-change="sizeChange" @current-change="pageChange"/>
  </div>
</template>
<script>
import initData from '@/mixins/initData'
import tableHeight from '@/mixins/tableHeight'
import { parseTime } from '@/utils/index'
export default {
  data () {
    return {

    }
  },
  mixins: [initData, tableHeight],
  methods: {
    parseTime,
    beforeInit () {
      this.url = 'api/tool/gen/page'
      return true
    },
    handleQuery () {
      this.page = 1
      this.init()
    }
  },
  created () {
    this.$nextTick(() => {
      this.init()
    })
  }
}
</script>
